home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************************
- *
- * Application: MacApp® Drafter, a sample C++ program by Danie Underwood
- *
- * File: UMacApp® Drafter.h
- *
- * Description: Main Program
- *
- * Apple Integrated Systems
- *
- * ©1990 Apple Computer, Inc. All rights reserved.
- *
- ********************************************************************************/
-
- #ifndef __UDrafter__
- #define __UDrafter__ 0
- #endif
-
- #if ! __UDrafter__
- #define __UDrafter__ 1
-
- #include "UMacAppUtilities.h"
- #include "UPrinting.h"
- #include "UTEView.h"
- #include "UGridView.h"
- #include "UDialog.h"
- #include "Memory.h"
- #include "Packages.h"
- #include "ToolUtils.h"
- #include "Errors.h"
- #include "Files.h"
- #include "Fonts.h"
- #include "Resources.h"
- #include "StdIO.h"
- #include "Strings.h"
-
- #include "UMacApp.h"
-
- //••••• Temporary until MPW catches up
- struct XWEventInfo {
- WindowPtr ownerWindow;
- EventRecord theEvent;
- long eventParams[10];
- };
-
- typedef struct XWEventInfo XWEventInfo;
- typedef XWEventInfo *XWEventInfoPtr;
-
- //General view signatures for use in dialogs and windows everywhere:
-
- const long vMainView ='MAIN';
- const long vTEView ='EDIT';
- const long vNoView ='NO__';
- const long vYesView ='YES_';
-
- //Specific view signatures:
-
- const long vAuthors ='AUTH';
- const long vAppName ='EDIT'; //first selected TE in dialog
- const long vCopyRight ='©CPY';
- const long vHasDocs ='DOCS';
- const long vDocBndl ='DBND';
- const long vHasPrefs ='PREF';
- const long vFreeWinds ='FREW';
- const long vPrints ='PRNT';
- const long vSplashes ='SPLH';
- const long vAppSig ='EDIT'; //first selected TE in dialog
- const long vAppSigHex ='ASGH';
- const long vMinMem ='MINM';
- const long vDefaultMem ='DEFM';
- const long vVersDVL ='VDVL';
- const long vVersAlpha ='VALP';
- const long vVersBeta ='VBTA';
- const long vVersRls ='VRLS';
- const long vReleaseNo ='RLSN';
- const long vVersNo ='VRSN';
- const long vBuildNo ='BLDN';
- const long vAppIcon ='AICN';
- const long vDocIcon ='DICN';
- const long vPrefFileName ='EDIT';
- const long vSys7PrefLoc ='SY7P';
- const long vSys6PrefLoc ='SY6P';
- const long vAppPrefLoc ='APPF';
- const long vFileSet ='FSET';
- const long vOneSourceFile ='1FIL';
- const long vStdSourceFiles ='SFIL';
- const long vStdNoInclSrcFil ='SNIF';
- const long vMainName ='EDIT';
- const long vPascal ='PASC';
- const long vCPlusPlus ='C++_';
- const long vDocSig ='DSIG';
- const long vDocSigAlt ='EDIT';
- const long vDocSigHex ='DSHX';
- const long vReadCluster ='RCLS';
- const long vWriteCluster ='WCLS';
- const long vDocReads ='DREA';
- const long vDocWrites ='DWRI';
- const long vReadData ='DRDT';
- const long vReadRsrc ='DRRS';
- const long vRDataOpen ='DRDO';
- const long vRRsrcOpen ='DRRO';
- const long vWriteData ='DWDT';
- const long vWriteRsrc ='DWRS';
- const long vWDataOpen ='DWDO';
- const long vWRsrcOpen ='DWRO';
- const long vDocReverts ='DRVT';
- const long vUsesLists ='ULST';
- const long vUsesAssoc ='UASS';
- const long vViewsRefViews ='VRVW';
- const long vViewsArePrefs ='VWPF';
- const long vSepPrintViews ='PRVW';
- const long vUseGridView ='GRDV';
- const long vUseTEView ='TEVW';
- const long vUseDialogView ='DLGV';
- const long vAppDoesMenus ='AMNU';
- const long vWdwDoesMenus ='WMNU';
- const long vDocDoesMenus ='DMNU';
- const long vViewDoesMenus ='VMNU';
- const long vPopMenus ='PMNU';
- const long vTearMenus ='TMNU';
-
- //Button view signatures for linking between screens like HyperCard® buttons:
-
- const long vMainScreen ='1001';
- const long vMainScreenValue =1001; //Numeric equivalent of vMainScreen
- const long vAppInfo ='1002';
- const long vFinderInfo ='1003';
- const long vPrefs ='1004';
- const long vDocs ='1005';
- const long vDocViews ='1006';
- const long vPgmFiles ='1007';
- const long vMenus ='1008';
- const long vGenerateOutput ='1111'; //••Exception- this button is different!
- const long vGenOutputValue =1111; //Numeric equivalent of vGenerateOutput
-
- //File pass constants
-
- const short kMainFile =1;
- const short kInterfaceFile =2;
- const short kImplementationFile =4;
- const short kResource =8;
- const short kMakeFile =16;
-
-
-
-
-
- //This class defines a special TWindow for the standard file package’s window.
-
- class TClearWindow : public TWindow {
- public:
- ResType fDismissView; //Who dismissed me?
- short fSFHitItem; //What item number was last hit?
-
- virtual pascal void IWindow(TDocument *itsDocument,GrafPtr itsWMgrWindow,Boolean canResize,
- Boolean canClose,Boolean disposeOnFree);
- virtual pascal void Free(void);
- virtual pascal void Activate(Boolean entering);
- virtual pascal Boolean AllowsMenuAccess(void);
- virtual pascal void DrawContents(void);
- virtual pascal ResType GetDisMissView(void);
- virtual pascal Boolean HandleMouseDown(VPoint *theMouse,EventInfo *info,Point *hysteresis,struct TCommand **theCommand);
- virtual pascal void HitItem(short itemNumber);
- virtual pascal short LastItemHit(void);
- virtual pascal void SetDisMissView(ResType viewId);
- virtual pascal void Update(void);
- };
-
- //This class defines a special TDialogView for the standard file package’s window.
-
- class TClearDialog : public TDialogView {
- public:
-
- virtual pascal void DoChoice(TView *origView,short itsChoice);
- virtual pascal void Draw(Rect *area);
- virtual pascal void SetOkEnable(Boolean okIsOn);
- };
-
-
- //This class defines a TCluster with split drawing methods and subview clip out.
- //It also coordinates its states with its subviews.
-
- class TDrafterCluster : public TCluster {
- public:
-
- virtual pascal void Draw(Rect *area);
- virtual pascal void DrawInterior(Rect *area,Rect *insideRect);
- virtual pascal void DimState(Boolean state, Boolean redraw);
- virtual pascal void DrawTitle(Rect *area);
- virtual pascal Boolean SetClipRgn(void);
- };
-
- //This class defines a TDrafterCluster but without the subview clip out.
-
- class TDrafterNoClipCluster : public TDrafterCluster {
- public:
-
- virtual pascal Boolean SetClipRgn(void);
- };
-
- //This class defines a TDrafterCluster with shadowed borders.
-
- class TDrafterFrameCluster : public TDrafterCluster {
- public:
-
- virtual pascal void Draw(Rect *area);
- virtual pascal void DrawInterior(Rect *area,Rect *insideRect);
- virtual pascal void DrawTitle(Rect *area);
- };
-
- //This class defines a TDrafterFrameCluster but without the subview clip out.
-
- class TDrafterHollowCluster : public TDrafterFrameCluster {
- public:
-
- virtual pascal Boolean SetClipRgn(void);
- };
-
- //This class defines a TDrafterHollowCluster painted in an RGBColor from a resource.
-
- class TDrafterBrassCluster : public TDrafterHollowCluster {
- public:
-
- virtual pascal void Draw(Rect *area);
- };
-
- //This class defines a TDrafterCluster that doesn’t draw at all.
- //It is only used to coordinate its subviews.
-
- class TDrafterClearCluster : public TDrafterCluster {
- public:
-
- virtual pascal void Draw(Rect *area);
- };
-
-
- //This class defines a TWindow that appears similar to a HyperCard background.
-
- class TDrafterWindow : public TWindow {
- public:
-
- virtual pascal void DrawContents(void);
- virtual pascal void SwitchDialog(short newViewId);
- };
-
-
- //This class defines a TButton that links screens like HyperCard buttons can.
-
- class TDrafterButton : public TButton {
- public:
- virtual pascal void Open(void);
- };
-
-
- //This class defines a TDialogTEView which is coordinated with other views.
-
- class TDrafterDialogTEView : public TDialogTEView {
- public:
-
- virtual pascal TCommand *DoKeyCommand(short ch, short aKeyCode, EventInfo *info);
- virtual pascal TTETypingCommand *DoMakeTypingCommand(short ch);
- virtual pascal TCommand *DoMenuCommand(CmdNumber aCmdNumber);
- };
-
- //This class defines a TDialogView that is similar to a HyperCard card.
-
- class TDrafterView : public TDialogView {
- public:
-
- virtual pascal void DoChoice(TView *origView,short itsChoice);
- virtual pascal class TDrafterDoc *GetDrafterDoc(void);
- virtual pascal struct TDialogTEView *MakeTEView(void);
- virtual pascal void Open(void);
- };
-
- //This class defines a TDrafterView for the general information screen.
-
- class TDlgGeneral : public TDrafterView {
- public:
-
- virtual pascal void Close(void);
- virtual pascal void DoChoice(TView *origView,short itsChoice);
- virtual pascal void Open(void);
- };
-
- //This class defines a TDrafterView for the Finder information screen.
-
- class TDlgFinderInfo : public TDrafterView {
- public:
-
- virtual pascal void Close(void);
- virtual pascal void DoChoice(TView *origView, short itsChoice);
- virtual pascal void Open(void);
- };
-
- //This class defines a TDrafterView for the preferences information screen.
-
- class TDlgPrefs : public TDrafterView {
- public:
-
- virtual pascal void Close(void);
- virtual pascal void Open(void);
- };
-
- //This class defines a TDrafterView for the document information screen.
-
- class TDlgDocs : public TDrafterView {
- public:
-
- virtual pascal void Close(void);
- virtual pascal void DoChoice(TView *origView, short itsChoice);
- virtual pascal void Open(void);
- };
-
- //This class defines a TDrafterView for the view information screen.
-
- class TDlgViews : public TDrafterView {
- public:
-
- virtual pascal void Close(void);
- virtual pascal void Open(void);
- };
-
- //This class defines a TDrafterView for the build screen.
-
- class TDlgBuild : public TDrafterView {
- public:
-
- virtual pascal void Close(void);
- virtual pascal void DoChoice(TView *origView, short itsChoice);
- virtual pascal void Open(void);
- };
-
- //This class defines a TDrafterView for the menus screen.
-
- class TDlgMenus : public TDrafterView {
- public:
-
- virtual pascal void Close(void);
- virtual pascal void Open(void);
- };
-
-
-
- //This class defines a TDocument as a general data storage object.
-
- class TDrafterDoc : public TDocument {
- public:
- long fSpinState; //Busy cursor state
- TAssociation *fWhatsBeenSeen; //A set of buttons that have been clicked.
-
- TIcon *fAppIcon; //NOT IMPLEMENTED
- TIcon *fDocIcon; //NOT IMPLEMENTED
- OSType fSignature; //USER:Application’s signature
- OSType fDocType; //USER:Document’s file type
- long fMinMem; //USER:SIZE resource min
- long fStandardMem; //USER:SIZE resource standard
- short fVersVersion; //USER:version number
- short fVersRelease; //USER:release number
- short fVersBuild; //USER:version.release build number
- Byte fVersType; //USER:final, beta, alpha or development
- Boolean fFreeWindows; //USER:it has free windows
- Boolean fHasPrefs; //USER:it has preference file
- Boolean fPrefInSystem6; //USER:store prefs system 6 place
- Boolean fPrefInSystem7; //USER:store prefs system 7 place
- Boolean fPrefWithApp; //USER:store prefs with app
- Boolean fOneFile; //USER:generate one program source file
- Boolean fUseIncludes; //USER:generate implementation include file
- Boolean fPascal; //USER:generate Object Pascal
- Boolean fFloaters; //USER:it has floatoids
- Boolean fTearOffMenus; //USER:it has tear offs
- Boolean fHierMenus; //USER:it has hierarchials
- Boolean fSplash; //USER:it has a splash screen
- Boolean fLaunchWithDoc; //USER:it defaults to untitled doc
- Boolean fHasDocs; //USER:it has documents
- Boolean fPrints; //USER:it prints
- Boolean fAssociation; //USER:it uses associations
- Boolean fLists; //USER:it uses lists
- Boolean fTEView; //USER:it uses text edit views
- Boolean fDialogView; //USER:it uses dialogs
- Boolean fGridView; //USER:it uses gridviews
- Boolean fAppDoesMenuCommands; //USER:it has application wide commands
- Boolean fWindowDoesMenuCommands; //USER: windows own commands
- Boolean fDocDoesMenuCommands; //USER: documents own commands
- Boolean fViewDoesMenuCommands; //USER: views own commands
- Boolean fDocReadData; //USER:docs read
- Boolean fDocWriteData; //USER:docs write
- Boolean fDocReadRsrc; //USER:docs read resources
- Boolean fDocWriteRsrc; //USER:docs write resources
- Boolean fDocDataStaysOpen; //USER:docs keep file open
- Boolean fDocRsrcStaysOpen; //USER:docs keep resources open
- Boolean fDocReverts; //USER:doc can revert
- Boolean fViewsRefViews; //USER:views are networked together
- Boolean fViewsSaveInPref; //USER:view resources are written
- Boolean fSeparatePrintView; //USER:print views differ from screen views
- Str31 fPrefFileName; //USER:name of preference file
- Str31 fAppName; //USER:name of application
- Str31 fPGMAppName; //USER:program name
- Str255 fCopyRight; //USER:copyright string
- Str255 fAuthors; //USER:author name string
-
- virtual pascal void IDrafterDoc(void);
- virtual pascal void Initialize(void);
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- virtual pascal void Abandon(void);
- virtual pascal void DoChoice(TView *origView,short itsChoice);
- virtual pascal void DoInitialState(void);
- virtual pascal void DoMakeViews(Boolean forPrinting);
- virtual pascal void DoSetupMenus(void);
- virtual pascal void EnumerateInfo(class TTranscriber *transcriber,Handle text,short kind);
- virtual pascal Boolean HaveSeen(StringPtr key);
- virtual pascal void SpinControl(Boolean switchOn);
- virtual pascal void SpinTheCursor(void);
- virtual pascal void WriteMacAppWorld(void);
- };
-
-
-
- //This class defines a TObject performs text editing and file generation.
-
- class TTranscriber : public TObject {
- public:
- TDrafterDoc *fDocument;
- short fFileRefNum;
- Boolean fSingleFile;
- Boolean fIncludes;
-
- virtual pascal void ITranscriber(TDrafterDoc *doc,Boolean useSingleFile,Boolean useIncludes);
- virtual pascal void Initialize(void);
- virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short
- fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
- virtual pascal OSErr CloseFile(void);
- virtual pascal void EditSection(Boolean condition,Handle data,const Str31 tagName);
- virtual pascal void FileNameForOutput(StringPtr fileName,short kind);
- virtual pascal Handle GetRawData(short kind);
- virtual pascal OSErr OpenFile(const Str255 name,short volRefNum,long dirId);
- virtual pascal void Substitute(Handle data,const Str255 tag,const Str255 textValue);
- virtual pascal OSErr WriteHandle(Handle fileText);
- virtual pascal void WriteProgram(short vRefNum,long dirId);
- virtual pascal void WriteProgramFile(short vRefNum,long dirId,short kind,Handle fileText);
- };
-
- //This class defines a TTranscriber sensitive to Object Pascal conventions.
-
- class TPascalTranscriber : public TTranscriber {
- public:
-
- virtual pascal void FileNameForOutput(StringPtr fileName,short kind);
- virtual pascal Handle GetRawData(short kind);
- };
-
- //This class defines a TTranscriber sensitive to C++ conventions.
-
- class TCPlusPlusTranscriber : public TTranscriber {
- public:
-
- virtual pascal void FileNameForOutput(StringPtr fileName,short kind);
- virtual pascal Handle GetRawData(short kind);
- };
-
-
-
- //This class defines a TApplication that gives us MacApp® Drafter.
-
- class TDrafterApplication : public TApplication {
- public:
-
- virtual pascal void IDrafterApplication(void);
- virtual pascal struct TDocument *DoMakeDocument(CmdNumber itsCmdNumber);
- virtual pascal TCommand *DoKeyCommand(short ch, short aKeyCode, EventInfo *info);
- virtual pascal void DoSetupMenus(void);
- virtual pascal Boolean PickFolder(short *volRefNum,long *dirId,Str255 *name,Boolean setDefaults);
- virtual pascal TWindow *WMgrToWindow(WindowPtr aWMgrWindow);
- };
-
- #endif
-